package org.hyl.javabase.model;

public class singleDemo {
    public static void main(String[] args){           
    	Singleton st= Singleton.getInstance();    
    	 st= Singleton.getInstance();  
    	 st= Singleton.getInstance();  
    	 st= Singleton.getInstance();  
    }   
}
class Singleton {  
	  
    /* ����˽�о�̬ʵ������ֹ�����ã��˴���ֵΪnull��Ŀ����ʵ���ӳټ��� */  
    private static Singleton instance = null;  
  
    /* ˽�й��췽������ֹ��ʵ���� */  
    private Singleton() {  
    }  
  
    /* ��̬���̷���������ʵ�� */  
    public static Singleton getInstance() {  
        if (instance == null) {  
            instance = new Singleton();  
        }  
        return instance;  
    }  
    public static Singleton getSynInstance() {  
        if (instance == null) {  
            synchronized (instance) {  
                if (instance == null) {  
                    instance = new Singleton();  
                }  
            }  
        }  
        return instance;  
    }  
    /* ����ö����������л������Ա�֤���������л�ǰ�󱣳�һ�� */  
    public Object getObject() {  
        return instance;  
    }  
}